//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
//
//
// (C) Copyright 2006 Marvell International Ltd.
// All Rights Reserved
//

#ifndef __OV5623_H__
#define __OV5623_H__

#include "sensor.h"

class Ov5623 : public Sensor
{
public:
    Ov5623();
    bool detect();
    unsigned int get_formats(ULONG type, PCS_DATARANGE_VIDEO** formats);
    void set_disable();
    void set_power_mode(bool is_on);
    void set_frame_format(int format, FrameSize size);
    void start_capture();
    void stop_capture();
    camera_cfg_t* get_camera_cfg(PCS_VIDEOINFOHEADER pCsVideoInfoHdr, ULONG mode);
    void handle_frame_interrupt(PUCHAR buf,
                                CS_BITMAPINFOHEADER* info_header,
                                frame_t* frame);
    void handle_frame_raw10(PUCHAR buf, frame_t* frame);
private:
    FrameSize frame_size;
    IppiRawPixProcSpec_P3R* rpp_uxga;
    IppiRawPixProcSpec_P3R* rpp_cif;
    IppiRawPixProcSpec_P3R* rpp_mcu;
    IppiRawPixProcSpec_P3R* rpp_qxga;
    IppiRawPixProcSpec_P3R* rpp_full;
    void write_sensor_reg(UCHAR addr, UCHAR data);
    void set_exposure_gain(USHORT time, USHORT gain);

    // Exposure and gain.
    int field_protect();
    int calculate_exp();
    ULONG field_pclk;
    ULONG field_max_line;
    ULONG field_max_pixel;

    UCHAR field_gain;
    ULONG field_exp; 
    UCHAR field_blueg;
    UCHAR field_redg; 
};

#endif